//
//  UserHeaderCell.m
//  LPTClient
//
//  Created by apple on 2018/12/6.
//  Copyright © 2018 zhaodd. All rights reserved.
//

#import "UserHeaderCell.h"
//#import ""

@interface UserHeaderCell()

@property (nonatomic, weak) IBOutlet UIImageView *iconImageView;
@property (nonatomic, weak) IBOutlet UILabel *nickNameLab;

@property (nonatomic, weak) IBOutlet UILabel *lab1;
@property (nonatomic, weak) IBOutlet UILabel *lab2;
@property (nonatomic, weak) IBOutlet UILabel *lab3;

@end

@implementation UserHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)refreshWithLogin:(BOOL)isLogin data:(UserInfoModel *)model
{
    if (isLogin) {
        
        NSString *str = model.doctor.credential.name;
        NSString *url = model.doctor.credential.figure_file.url;
        
        [self.iconImageView setImageWithURL:[NSURL URLWithString:IMG_URL(url)] placeholder:[UIImage imageNamed:@"my_nav_portrait"]];
        if (str) {
            NSMutableAttributedString *mutableAttributedStr = [[NSMutableAttributedString alloc] initWithString:str];
            [mutableAttributedStr setAttributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:15] } range:NSMakeRange(0, str.length)];
            self.nickNameLab.attributedText = mutableAttributedStr;
        }
        
        // 三个数字
        self.lab1.text = model.doctor.visit_count;
        self.lab2.text = model.doctor.patient_count;
        self.lab3.text = model.doctor.score;
        
    }else {
        
        NSString *preStr = @"立即注册/登录";
        NSString *rightStr = @"注册登录查看更多内容";
        
        NSString *str = [NSString stringWithFormat:@"%@\n%@", preStr,rightStr];
        
        NSMutableAttributedString *mutableAttributedStr = [[NSMutableAttributedString alloc] initWithString:str];
        
        [mutableAttributedStr setAttributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:18] } range:NSMakeRange(0, preStr.length)];
        [mutableAttributedStr setAttributes:@{ NSFontAttributeName: [UIFont systemFontOfSize:12] } range:NSMakeRange(preStr.length, rightStr.length + 1)];
        
        self.nickNameLab.numberOfLines = 0;
        self.nickNameLab.attributedText = mutableAttributedStr;
        
    }
}


@end
